import axios from 'axios';

import {
  WaterQualityRecord,
  WaterQualityParams,
  WaterQualityPageResponse,
  WaterQualityListParams,
  WaterQualityListResponse,
  CategoryRecord,
  WaterTemperatureRecord,
  RelevanceRecord,
  PhDistributionRecord,
  TurbidityRecord,
} from './types';

// 分页查询
export function queryWaterQualityPage(data: WaterQualityListParams) {
  return axios.post<WaterQualityPageResponse>(
    `/api/waterQuality/page/${data.current}/${data.pageSize}`,
    data
  );
}

// 模糊查询
export function queryWaterQuality(data?: WaterQualityListParams) {
  return axios.post<WaterQualityListResponse>(`/api/waterQuality/query`, data);
}

// 添加
export function addWaterQuality(data: WaterQualityParams) {
  return axios.post<WaterQualityRecord>(`/api/waterQuality`, data);
}

// 删除
export function delWaterQuality(id: number) {
  return axios.delete<WaterQualityRecord>(`/api/waterQuality/${id}`);
}

// 修改
export function editWaterQuality(data: WaterQualityParams) {
  return axios.put<WaterQualityRecord>(`/api/waterQuality`, data);
}

export function categoryDistribution(province: string) {
  return axios.get<CategoryRecord[]>(
    `/api/waterQuality/categoryDistribution/${province}`
  );
}

export function waterTemperatureChange() {
  return axios.get<WaterTemperatureRecord[]>(
    `/api/waterQuality/waterTemperatureChange`
  );
}
export function phDistribution() {
  return axios.get<PhDistributionRecord[]>(`/api/waterQuality/phDistribution`);
}
export function relevance() {
  return axios.get<RelevanceRecord[]>(`/api/waterQuality/relevance`);
}
export function turbidityDistribution() {
  return axios.get<TurbidityRecord[]>(
    `/api/waterQuality/turbidityDistribution`
  );
}
